SE2840 Web Application Development
Lab 6: Forms and JSP-based servlets

Assignment

In this assignment, you will recast the InfoServlet from the previous lab as a JSP-based servlet, and use a form to submit data to the InfoServlet.

Details

Create a new Dynamic Web Application project in J2EE Eclipse named <yourname>-Lab6. (Your name is important in order to distinguish your web application from others when they are all deployed to the remote sapphire.msoe.edu linux server.)

In this lab, your web application must have a default static web page (lab6.html) that implements a simple form that allows you to enter 140-character messages (download this partially-completed lab6.html and follow the TODO instructions):

When this form is submitted, the message you enter is sent to your JSP-based InfoServlet, which produces output similar to the Java-based InfoServlet of the previous lab (the Request Parameters appear at the top in this rendition):

Your Servlet must be implemented as InfoServlet.jsp, but whose and url must be info.do)

Advice: Begin by implementing the lab6.html form, and posting the results to the Java-based InfoServlet from the previous lab. Work out any bugs you might encounter in the form creation and submission first, and make sure that your form can be correctly submitted to the server-side. After you get this working, move on to implementing InfoServlet.jsp.

To help you get started in writing the JSP version of InfoServlet, here is a code snippet that produces the first few lines of the output shown above:

Note: Avoid the use of out.println() for outputting the static part of the html output. Make the html portion of the jsp file look as much like "regular" html as possible.

The output produced by InfoServlet.jsp (validated for no HTML/CSS errors) is almost identical to that of the previous lab's:

bulletA Request Parameters section in blue, which echoes every request parameter supplied in the url. Note that there may be 0 or many of these, but your lab6.html will only supply two.
bulletNEW: A "return to form" link below the Request Parameters that, when pressed, causes the lab6.html form to reappear.
bulletA "navigation bar" that appears at the top, used to select (via jQuery) one of the four sections below. The elements in the navigation bar get highlighted when you pass the mouse over them, and respond to mouse clicks to display:
bulletA System Info section that reports information about the server's environment (see the regular old Java System and Thread classes)
bulletA Request Info section that displays information about the request made by the browser. The table displaying this information appears with rows alternating between green and white (both text and background) after the table header (white text with black background), and black borders around the cells (thinner on the inside).
bulletAn HTTP Headers section appearing in brown, that displays information about the HTTP headers in the request coming from the browser. The number of header elements varies according to the browser being used.

Submission

When you have finished,

1. zip your Eclipse src and WebContent folders (NOT the entire project folder) and submit it to Blackboard.

2. Deploy your application to the sapphire server via this Tomcat Web Manager Application link. (Note1: When prompted for a username and password, enter "tomcat" for both. This application uses Tomcat-based security, which you'll learn about later in this course. Note2: you need to either use a VPN or be on-campus to be allowed to access the sapphire server over the network). At the bottom of the Tomcat Web Manager page, you'll see a Deploy section with two forms (Deploy Directory... and WAR file to deploy). Use the War file to deploy form to browse to the location on your local PC filesystem where you created the .war file containing your web application. Note: You create the .war file from within Eclipse by selecting your project and choosing the Export... command from either the main File menu or the context-menu that appears when you right-click on your project.

Be prepared to demonstrate your application running both locally on your laptop as well as on sapphire, using the code you submitted.